package com.loan.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.loan.entity.ResponseResult;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class WebUtil {
    /**
     * 发送json响应消息
     * @param response
     * @param result
     * @throws IOException
     */
    public static void sendJsonResult(HttpServletResponse response, ResponseResult result) throws IOException {
        ObjectMapper objectMapper = new ObjectMapper();
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().print(objectMapper.writeValueAsString(result));
    }

}
